<template>
  <div class="footerbox flexrow">
    <span>全国服务电话：{{ tel }}</span>
    <span>数据日期：{{ time }}</span>
    <span v-if="username">当前用户：<span class="bluefont">{{ username }}</span></span>
  </div>
</template>
<script>
import axios from 'axios'

export default {
  name: 'HomeFooter',
  props: ['username'],
  data() {
    return {}
  },
  computed: {
    tel() {
      return this.$store.state.call_center
    },
    time() {
      return this.$store.state.date_update_time
    },
  },
  methods: {
    getFootInfo() {
      axios.get('/config/index')
          .then(this.getFootInfoSucc)
    },
    getFootInfoSucc(res) {
      res = res.data
      if (res.status == 200) {
        const data = res.data
        this.$store.dispatch('getFootTel', data.call_center)
        this.$store.dispatch('getFootTime', data.date_update_time)
        this.$store.dispatch('setYearStart', data.year_start || 1989)
      }
    }
  },
  mounted() {
    this.getFootInfo()
  }
}
</script>

<style scoped>
.flexrow{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.footerbox {
  width: 100%;
  height: 38px;
  line-height: 38px;
  font-size: 12px;
  color: gray;
  justify-content: between;
}

.bluefont {
  color: #2254E7;
}

</style>